home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Other / upsd / ups_folder / patch03.old < prev    next >
Encoding:
Internet Message Format  |  1991-05-01  |  22.4 KB

  1. From: art@pilikia.pegasus.com (Authur W. Neilson III)
  2. Newsgroups: comp.sources.misc
  3. Subject: v18i055:  upsd - UPS monitor daemon, Patch03
  4. Message-ID: <1991Apr19.023955.7895@sparky.IMD.Sterling.COM>
  5. Date: 19 Apr 91 02:39:55 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: c95764b9 ef5092eb 8e0b4eaf 9d2c69ff
  8.  
  9. Submitted-by: Authur W. Neilson III <art@pilikia.pegasus.com>
  10. Posting-number: Volume 18, Issue 55
  11. Archive-name: upsd/patch03
  12. Patch-To: upsd: Volume 18, Issue 5
  13.  
  14. This is an update to the UPS monitor daemon.  The update consists of
  15. 3 new files and the patchfile, "Patch03".   New features are the
  16. broadcast of power fail and restore messages from user specified
  17. ASCII files and a man page for upsd(1M).  Unshar this article
  18. in your upsd source directory and feed the file "Patch03" to
  19. Larry Wall's patch utility like so:
  20.  
  21.         patch < Patch03
  22. Mahalo!
  23.  
  24. Art.
  25. -----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----
  26. #! /bin/sh
  27. # This is a shell archive.  Remove anything before this line, then unpack
  28. # it by saving it into a file and typing "sh file".  To overwrite existing
  29. # files, type "sh file -c".  You can also feed this as standard input via
  30. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  31. # will see the following message at the end:
  32. #        "End of shell archive."
  33. # Contents:  Patch03 upsd.1 upsfail upsrest
  34. # Wrapped by root@pilikia on Mon Apr 15 23:27:34 1991
  35. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  36. if test -f 'Patch03' -a "${1}" != "-c" ; then 
  37.   echo shar: Will not clobber existing file \"'Patch03'\"
  38. else
  39. echo shar: Extracting \"'Patch03'\" \(15648 characters\)
  40. sed "s/^X//" >'Patch03' <<'END_OF_FILE'
  41. X*** HISTORY.orig    Mon Apr 15 23:25:28 1991
  42. X--- HISTORY    Mon Apr 15 23:26:03 1991
  43. X***************
  44. X*** 1,3 ****
  45. X--- 1,4 ----
  46. X+ 
  47. X  UPSD RELEASE HISTORY    art@pilikia.pegasus.com
  48. X  
  49. X  Date      Release  Patch  Description
  50. X***************
  51. X*** 7,9 ****
  52. X--- 8,13 ----
  53. X                            added version stuff.
  54. X  04/10/91  1.0      2      Added log file locking, only 1 upsd can be running
  55. X                            now.  Also added date to version string.
  56. X+ 04/15/91  1.0      3      Added broadcast of power fail and restore messages,
  57. X+                           defined message file names as new command line and
  58. X+                           environment variable parameters.  Also made man page.
  59. X*** MANIFEST.orig    Mon Apr 15 23:25:28 1991
  60. X--- MANIFEST    Mon Apr 15 23:26:03 1991
  61. X***************
  62. X*** 8,11 ****
  63. X--- 8,14 ----
  64. X   funcs.c                    1    Functions 
  65. X   main.c                     1    Main program
  66. X   ups                        1    Init.d startup script
  67. X+  upsd.1                     1    Upsd man page
  68. X+  upsfail                    1    UPS failure message file
  69. X+  upsrest                    1    UPS restore message file
  70. X   version.h                  1    Version control header
  71. X*** Makefile.orig    Mon Apr 15 23:25:28 1991
  72. X--- Makefile    Mon Apr 15 23:26:03 1991
  73. X***************
  74. X*** 11,24 ****
  75. X  CC = cc
  76. X  DEFS =
  77. X  CFLAGS = -O $(DEFS)
  78. X  CFILES = main.c funcs.c
  79. X  OFILES = main.o funcs.o
  80. X  HFILES = common.h
  81. X! LIBES =
  82. X  DESTDIR = /etc
  83. X  INITDIR = /etc/init.d
  84. X  RC2DIR = /etc/rc2.d
  85. X  RC2NUM = 22
  86. X  
  87. X  upsd: $(OFILES)
  88. X      $(CC) $(CFLAGS) $(OFILES) -o $@ $(LIBES)
  89. X--- 11,27 ----
  90. X  CC = cc
  91. X  DEFS =
  92. X  CFLAGS = -O $(DEFS)
  93. X+ LIBES =
  94. X+ 
  95. X  CFILES = main.c funcs.c
  96. X  OFILES = main.o funcs.o
  97. X  HFILES = common.h
  98. X! 
  99. X  DESTDIR = /etc
  100. X  INITDIR = /etc/init.d
  101. X  RC2DIR = /etc/rc2.d
  102. X  RC2NUM = 22
  103. X+ MANDIR = /usr/catman/u_man/man1
  104. X  
  105. X  upsd: $(OFILES)
  106. X      $(CC) $(CFLAGS) $(OFILES) -o $@ $(LIBES)
  107. X***************
  108. X*** 31,37 ****
  109. X      chgrp sys $(DESTDIR)/upsd
  110. X      chmod 550 $(DESTDIR)/upsd
  111. X  
  112. X! install_rc: install
  113. X      cp ups $(INITDIR)/ups
  114. X      chown root $(INITDIR)/ups
  115. X      chgrp sys $(INITDIR)/ups
  116. X--- 34,40 ----
  117. X      chgrp sys $(DESTDIR)/upsd
  118. X      chmod 550 $(DESTDIR)/upsd
  119. X  
  120. X! install_rc:
  121. X      cp ups $(INITDIR)/ups
  122. X      chown root $(INITDIR)/ups
  123. X      chgrp sys $(INITDIR)/ups
  124. X***************
  125. X*** 38,43 ****
  126. X--- 41,57 ----
  127. X      chmod 744 $(INITDIR)/ups
  128. X      ln $(INITDIR)/ups $(RC2DIR)/S$(RC2NUM)ups
  129. X  
  130. X+ install_msg:
  131. X+     cp upsfail upsrest $(DESTDIR)
  132. X+     chown root $(DESTDIR)/upsfail $(DESTDIR)/upsrest
  133. X+     chgrp sys $(DESTDIR)/upsfail $(DESTDIR)/upsrest
  134. X+     chmod 644 $(DESTDIR)/upsfail $(DESTDIR)/upsrest
  135. X+ 
  136. X+ install_man:
  137. X+     rm -f $(MANDIR)/upsd.1.z
  138. X+     nroff -man upsd.1 > $(MANDIR)/upsd.1
  139. X+     pack $(MANDIR)/upsd.1
  140. X+ 
  141. X  indent:
  142. X      @for f in $(CFILES); do \
  143. X          indent $$f; \
  144. X***************
  145. X*** 50,56 ****
  146. X      rm -f upsd core *.o *.BAK Part*
  147. X  
  148. X  clobber: clean
  149. X!     rm -f $(DESTDIR)/upsd $(INITDIR)/ups $(RC2DIR)/S$(RC2NUM)ups
  150. X  
  151. X  # dependencies
  152. X  main.o:        main.c $(HFILES)
  153. X--- 64,71 ----
  154. X      rm -f upsd core *.o *.BAK Part*
  155. X  
  156. X  clobber: clean
  157. X!     rm -f $(DESTDIR)/upsd $(DESTDIR)/upsfail $(DESTDIR)/upsrest
  158. X!     rm -f $(INITDIR)/ups $(RC2DIR)/S$(RC2NUM)ups
  159. X  
  160. X  # dependencies
  161. X  main.o:        main.c $(HFILES)
  162. X*** README.orig    Mon Apr 15 23:25:28 1991
  163. X--- README    Mon Apr 15 23:26:03 1991
  164. X***************
  165. X*** 1,4 ****
  166. X!      Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 1
  167. X   
  168. X  
  169. X      INTRODUCTION
  170. X--- 1,4 ----
  171. X!      upsd release 03/30/91 version 1.0 patchlevel 3            Pg. 1
  172. X   
  173. X  
  174. X      INTRODUCTION
  175. X***************
  176. X*** 24,30 ****
  177. X      in the /etc directory when the install target is made.  
  178. X  
  179. X  
  180. X!      Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 2
  181. X  
  182. X  
  183. X      COMMAND LINE OPTIONS
  184. X--- 24,30 ----
  185. X      in the /etc directory when the install target is made.  
  186. X  
  187. X  
  188. X!      upsd release 03/30/91 version 1.0 patchlevel 3            Pg. 2
  189. X  
  190. X  
  191. X      COMMAND LINE OPTIONS
  192. X***************
  193. X*** 34,43 ****
  194. X      take precedence to the environment variable settings, and are
  195. X      as follows:
  196. X  
  197. X!     usage: upsd [-d tty][-c cmd][-l log][-t min]
  198. X          -d tty        pathname of UPS device
  199. X          -c cmd        pathname of shutdown command
  200. X!         -l log        pathname of UPS log file
  201. X          -t min        delay time in minutes
  202. X  
  203. X      The -d tty option must specify the full pathname (including the
  204. X--- 34,45 ----
  205. X      take precedence to the environment variable settings, and are
  206. X      as follows:
  207. X  
  208. X!     usage: upsd [-d tty][-c cmd][-l file][-t min][-f file][-r file]
  209. X          -d tty        pathname of UPS device
  210. X          -c cmd        pathname of shutdown command
  211. X!         -l file        pathname of UPS log file
  212. X!         -f file        pathname of UPS fail message file
  213. X!         -r file        pathname of UPS restore message file
  214. X          -t min        delay time in minutes
  215. X  
  216. X      The -d tty option must specify the full pathname (including the
  217. X***************
  218. X*** 53,61 ****
  219. X  
  220. X      Example:
  221. X  
  222. X!     upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0"
  223. X  
  224. X!     The -l option specified the logfile upsd will write it's event
  225. X      messages to, these messages give the date and time that the UPS
  226. X      daemon started, switched to battery, switched back to online,
  227. X      executed the shutdown command, or was terminated via SIGTERM.
  228. X--- 55,63 ----
  229. X  
  230. X      Example:
  231. X  
  232. X!     upsd -c "/etc/shutdown -y -i0"
  233. X  
  234. X!     The -l option specifies the logfile upsd will write it's event
  235. X      messages to, these messages give the date and time that the UPS
  236. X      daemon started, switched to battery, switched back to online,
  237. X      executed the shutdown command, or was terminated via SIGTERM.
  238. X***************
  239. X*** 62,69 ****
  240. X  
  241. X      Example:
  242. X  
  243. X!     upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0" -l /etc/upslog
  244. X  
  245. X      Finally, the -t option specifies the number of minutes to allow
  246. X      the UPS to be on battery backup before executing the shutdown
  247. X      sequence.  This number must be between 1 and 30.  Be careful not
  248. X--- 64,91 ----
  249. X  
  250. X      Example:
  251. X  
  252. X!     upsd -l /etc/upslog
  253. X  
  254. X+     The -f option specifies the path name of the failure message file
  255. X+     to broadcast to all users in the event of a power failure.  The
  256. X+     failure message file is simply an ASCII text file which you can
  257. X+     create with an editor such as vi(1). If the file is not found by
  258. X+     upsd, no message will be broadcast upon power failure.
  259. X+ 
  260. X+     Example:
  261. X+ 
  262. X+     upsd -f /etc/upsfail
  263. X+ 
  264. X+     The -r option specifies the path name of the restore message file
  265. X+     to broadcast to all users in the event of power restore.  The
  266. X+     restore message file is simply an ASCII text file which you can
  267. X+     create with an editor such as vi(1). If the file is not found by
  268. X+     upsd, no message will be broadcast upon power restore.
  269. X+ 
  270. X+     Example:
  271. X+ 
  272. X+     upsd -f /etc/upsrest
  273. X+ 
  274. X      Finally, the -t option specifies the number of minutes to allow
  275. X      the UPS to be on battery backup before executing the shutdown
  276. X      sequence.  This number must be between 1 and 30.  Be careful not
  277. X***************
  278. X*** 73,81 ****
  279. X  
  280. X      Example:
  281. X  
  282. X!     upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0" -l /etc/upslog -t 10
  283. X      
  284. X!      Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 3
  285. X  
  286. X  
  287. X      ENVIRONMENT VARIABLES
  288. X--- 95,103 ----
  289. X  
  290. X      Example:
  291. X  
  292. X!     upsd -t 10
  293. X      
  294. X!      upsd release 03/30/91 version 1.0 patchlevel 3            Pg. 3
  295. X  
  296. X  
  297. X      ENVIRONMENT VARIABLES
  298. X***************
  299. X*** 88,95 ****
  300. X      Environment    Equivalent        Default
  301. X      Variable    Command line option    Value
  302. X      UPSPORT            -p        /dev/ttyFM00
  303. X!     UPSSHUT            -c        "/etc/shutdown -y -g1 -i0"
  304. X      UPSLOG            -l        /etc/upslog
  305. X      UPSTIME            -t        10
  306. X  
  307. X      Note that the compiled in default values can be altered in common.h
  308. X--- 110,119 ----
  309. X      Environment    Equivalent        Default
  310. X      Variable    Command line option    Value
  311. X      UPSPORT            -p        /dev/ttyFM00
  312. X!     UPSSHUT            -c        "/etc/shutdown -y -i0"
  313. X      UPSLOG            -l        /etc/upslog
  314. X+     UPSFAIL            -f        /etc/upsfail
  315. X+     UPSREST            -r        /etc/upsrest
  316. X      UPSTIME            -t        10
  317. X  
  318. X      Note that the compiled in default values can be altered in common.h
  319. X*** common.h.orig    Mon Apr 15 23:25:28 1991
  320. X--- common.h    Mon Apr 15 23:26:03 1991
  321. X***************
  322. X*** 22,39 ****
  323. X  
  324. X  #define ERR        -1        /* error return value */
  325. X  #define SH        "/bin/sh"    /* shell to exec shutdown command */
  326. X! #define ROOT        "/"        /* root directory for chdir */
  327. X  #define CONSOLE        "/dev/console"    /* console device */
  328. X  #define SECS_PER_MIN    60        /* number of secs in a minute */
  329. X  #define MAX_TIME    30        /* maximum delay time allowed */
  330. X- #define SHUT_PERMS    0500        /* shutdown command permissions mask */
  331. X  #define LOG_PERMS    0600        /* logfile permissions on create */
  332. X  #define LOG_FLAGS    O_WRONLY | O_CREAT | O_APPEND    /* logfile open flags */
  333. X  
  334. X  /* default tuneable parameter values */
  335. X  #define UPS_PORT    "/dev/ttyFM00"    /* UPS port device name */
  336. X! #define UPS_SHUT    "/etc/shutdown -y -g0"    /* shutdown command */
  337. X  #define UPS_LOG        "/etc/upslog"    /* UPS log file pathname */
  338. X  #define UPS_TIME    10        /* default delay time (minutes) */
  339. X  
  340. X  /* environment variable names */
  341. X--- 22,41 ----
  342. X  
  343. X  #define ERR        -1        /* error return value */
  344. X  #define SH        "/bin/sh"    /* shell to exec shutdown command */
  345. X! #define WALL        "/etc/wall"    /* utility to broadcast messages */
  346. X  #define CONSOLE        "/dev/console"    /* console device */
  347. X+ #define ROOT        "/"        /* root directory for chdir */
  348. X  #define SECS_PER_MIN    60        /* number of secs in a minute */
  349. X  #define MAX_TIME    30        /* maximum delay time allowed */
  350. X  #define LOG_PERMS    0600        /* logfile permissions on create */
  351. X  #define LOG_FLAGS    O_WRONLY | O_CREAT | O_APPEND    /* logfile open flags */
  352. X  
  353. X  /* default tuneable parameter values */
  354. X  #define UPS_PORT    "/dev/ttyFM00"    /* UPS port device name */
  355. X! #define UPS_SHUT    "/etc/shutdown -y -i0"    /* shutdown command */
  356. X  #define UPS_LOG        "/etc/upslog"    /* UPS log file pathname */
  357. X+ #define UPS_FAIL    "/etc/upsfail"    /* UPS fail message file name */
  358. X+ #define UPS_REST    "/etc/upsrest"    /* UPS restore message file name */
  359. X  #define UPS_TIME    10        /* default delay time (minutes) */
  360. X  
  361. X  /* environment variable names */
  362. X***************
  363. X*** 40,45 ****
  364. X--- 42,49 ----
  365. X  #define UPSPORT        "UPSPORT"
  366. X  #define UPSSHUT        "UPSSHUT"
  367. X  #define UPSLOG        "UPSLOG"
  368. X+ #define UPSFAIL        "UPSFAIL"
  369. X+ #define UPSREST        "UPSREST"
  370. X  #define UPSTIME        "UPSTIME"
  371. X  
  372. X  /* UPS log messages */
  373. X***************
  374. X*** 54,59 ****
  375. X--- 58,65 ----
  376. X  extern char   *ups_port;        /* UPS device name */
  377. X  extern char   *ups_shut;        /* system shutdown command */
  378. X  extern char   *ups_log;            /* UPS log file name */
  379. X+ extern char   *ups_fail;        /* UPS failure message file name */
  380. X+ extern char   *ups_rest;        /* UPS restore message file name */
  381. X  extern int     ups_time;        /* delay time before shutdown */
  382. X  extern int     ups_fd;            /* UPS port descriptor */
  383. X  extern int     log_fd;            /* log file descriptor */
  384. X*** funcs.c.orig    Mon Apr 15 23:25:28 1991
  385. X--- funcs.c    Mon Apr 15 23:26:03 1991
  386. X***************
  387. X*** 26,31 ****
  388. X--- 26,35 ----
  389. X          ups_shut = s;
  390. X      if ((s = getenv(UPSLOG)) != NULL)
  391. X          ups_log = s;
  392. X+     if ((s = getenv(UPSFAIL)) != NULL)
  393. X+         ups_fail = s;
  394. X+     if ((s = getenv(UPSREST)) != NULL)
  395. X+         ups_rest = s;
  396. X      if ((s = getenv(UPSTIME)) != NULL)
  397. X          ups_time = atoi(s);
  398. X  }
  399. X***************
  400. X*** 52,58 ****
  401. X      version(av[0]);
  402. X  
  403. X      /* parse the command line */
  404. X!     while ((c = getopt(ac, av, "d:c:l:t:")) != EOF)
  405. X          switch (c) {
  406. X          case 'd':    /* device option */
  407. X              ups_port = optarg;
  408. X--- 56,62 ----
  409. X      version(av[0]);
  410. X  
  411. X      /* parse the command line */
  412. X!     while ((c = getopt(ac, av, "d:c:l:f:r:t:")) != EOF)
  413. X          switch (c) {
  414. X          case 'd':    /* device option */
  415. X              ups_port = optarg;
  416. X***************
  417. X*** 63,68 ****
  418. X--- 67,78 ----
  419. X          case 'l':    /* logfile option */
  420. X              ups_log = optarg;
  421. X              break;
  422. X+         case 'f':    /* failure option */
  423. X+             ups_fail = optarg;
  424. X+             break;
  425. X+         case 'r':    /* restore option */
  426. X+             ups_rest = optarg;
  427. X+             break;
  428. X          case 't':    /* time option */
  429. X              ups_time = atoi(optarg);
  430. X              break;
  431. X***************
  432. X*** 76,81 ****
  433. X--- 86,92 ----
  434. X  **    c h k o p t i o n s
  435. X  **
  436. X  **    check runtime options
  437. X+ **    with various sanity tests
  438. X  */
  439. X  void
  440. X  chkoptions()
  441. X***************
  442. X*** 103,111 ****
  443. X          perror(ups_shut);
  444. X          exit(1);
  445. X      }
  446. X!     /* and must be readable/executable by owner */
  447. X!     if (!(st.st_mode & SHUT_PERMS)) {
  448. X!         fprintf(stderr, "%s must be readable/executable by owner\n", ups_port);
  449. X          exit(1);
  450. X      }
  451. X      /* delay time must be > 0 and <= MAX_TIME */
  452. X--- 114,122 ----
  453. X          perror(ups_shut);
  454. X          exit(1);
  455. X      }
  456. X!     /* and must be a regular file */
  457. X!     if ((st.st_mode & S_IFMT) != S_IFREG) {
  458. X!         fprintf(stderr, "%s not regular\n", ups_port);
  459. X          exit(1);
  460. X      }
  461. X      /* delay time must be > 0 and <= MAX_TIME */
  462. X***************
  463. X*** 127,132 ****
  464. X--- 138,144 ----
  465. X  
  466. X      void    sigcatch();
  467. X      void    writelog();
  468. X+     void    writeall();
  469. X      void    shutdown();
  470. X  
  471. X      if (!fork()) {
  472. X***************
  473. X*** 166,171 ****
  474. X--- 178,186 ----
  475. X          }
  476. X          writelog(BATTERY_MSG);
  477. X  
  478. X+         /* broadcast failure message */
  479. X+         writeall(ups_fail);
  480. X+ 
  481. X          /* set the alarm clock */
  482. X          alarm(ups_time * SECS_PER_MIN);
  483. X  
  484. X***************
  485. X*** 175,180 ****
  486. X--- 190,198 ----
  487. X  
  488. X          writelog(ONLINE_MSG);
  489. X  
  490. X+         /* broadcast restore message */
  491. X+         writeall(ups_rest);
  492. X+ 
  493. X          close(log_fd);
  494. X          close(ups_fd);
  495. X  
  496. X***************
  497. X*** 191,198 ****
  498. X--- 209,218 ----
  499. X  sigcatch()
  500. X  {
  501. X      writelog(TERM_MSG);
  502. X+ 
  503. X      close(log_fd);
  504. X      close(ups_fd);
  505. X+ 
  506. X      exit(1);
  507. X  }
  508. X  
  509. X***************
  510. X*** 221,226 ****
  511. X--- 241,275 ----
  512. X  }
  513. X  
  514. X  /*
  515. X+ **    w r i t e a l l
  516. X+ **
  517. X+ **    write to all users
  518. X+ */
  519. X+ void
  520. X+ writeall(fn)
  521. X+ char   *fn;
  522. X+ {
  523. X+     struct stat st;
  524. X+     void    attach();
  525. X+ 
  526. X+     /* message file must exist */
  527. X+     if (stat(fn, &st) == ERR)
  528. X+         return;
  529. X+ 
  530. X+     /* and must be a regular file */
  531. X+     if ((st.st_mode & S_IFMT) != S_IFREG)
  532. X+         return;
  533. X+ 
  534. X+     if (!fork()) {
  535. X+ 
  536. X+         attach(CONSOLE);
  537. X+ 
  538. X+         /* write message file to users */
  539. X+         execlp(WALL, WALL, fn, NULL);
  540. X+     }
  541. X+ }
  542. X+ 
  543. X+ /*
  544. X  **    s h u t d o w n
  545. X  **
  546. X  **    shutdown the system
  547. X***************
  548. X*** 232,246 ****
  549. X  
  550. X      writelog(SHUTDOWN_MSG);
  551. X  
  552. X!     close(log_fd);
  553. X!     close(ups_fd);
  554. X  
  555. X!     attach(CONSOLE);
  556. X  
  557. X!     chdir(ROOT);
  558. X  
  559. X!     /* execute shutdown command */
  560. X!     execlp(SH, SH, "-c", ups_shut, NULL);
  561. X  }
  562. X  
  563. X  /*
  564. X--- 281,298 ----
  565. X  
  566. X      writelog(SHUTDOWN_MSG);
  567. X  
  568. X!     close(ups_log);
  569. X!     close(ups_port);
  570. X  
  571. X!     if (!fork()) {
  572. X! 
  573. X!         attach(CONSOLE);
  574. X  
  575. X!         chdir(ROOT);
  576. X  
  577. X!         /* execute shutdown command */
  578. X!         execlp(SH, SH, "-c", ups_shut, NULL);
  579. X!     }
  580. X  }
  581. X  
  582. X  /*
  583. X***************
  584. X*** 314,323 ****
  585. X  {
  586. X      char   *basename();
  587. X  
  588. X!     fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min][-v]\n",
  589. X!         basename(s));
  590. X      fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  591. X      fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  592. X!     fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n");
  593. X      fprintf(stderr, "\t-t min\t\tdelay time in minutes\n");
  594. X  }
  595. X--- 366,376 ----
  596. X  {
  597. X      char   *basename();
  598. X  
  599. X!     fprintf(stderr, "usage: %s [-d tty][-c cmd][-l file][-f file][-r file][-t min]\n", basename(s));
  600. X      fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  601. X      fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  602. X!     fprintf(stderr, "\t-l file\t\tpathname of UPS log file\n");
  603. X!     fprintf(stderr, "\t-f file\t\tpathname of UPS fail message file\n");
  604. X!     fprintf(stderr, "\t-r file\t\tpathname of UPS restore message file\n");
  605. X      fprintf(stderr, "\t-t min\t\tdelay time in minutes\n");
  606. X  }
  607. X*** main.c.orig    Mon Apr 15 23:25:28 1991
  608. X--- main.c    Mon Apr 15 23:26:03 1991
  609. X***************
  610. X*** 14,19 ****
  611. X--- 14,21 ----
  612. X  char   *ups_port = UPS_PORT;
  613. X  char   *ups_shut = UPS_SHUT;
  614. X  char   *ups_log = UPS_LOG;
  615. X+ char   *ups_fail = UPS_FAIL;
  616. X+ char   *ups_rest = UPS_REST;
  617. X  int     ups_time = UPS_TIME;
  618. X  
  619. X  /* global descriptors */
  620. X*** version.h.orig    Mon Apr 15 23:25:28 1991
  621. X--- version.h    Mon Apr 15 23:26:03 1991
  622. X***************
  623. X*** 11,14 ****
  624. X  #define RELEASE_DATE    "03/30/91"
  625. X  #define RELEASE        1
  626. X  #define REVISION    0
  627. X! #define PATCHLEVEL    2
  628. X--- 11,14 ----
  629. X  #define RELEASE_DATE    "03/30/91"
  630. X  #define RELEASE        1
  631. X  #define REVISION    0
  632. X! #define PATCHLEVEL    3
  633. END_OF_FILE
  634. if test 15648 -ne `wc -c <'Patch03'`; then
  635.     echo shar: \"'Patch03'\" unpacked with wrong size!
  636. fi
  637. # end of 'Patch03'
  638. fi
  639. if test -f 'upsd.1' -a "${1}" != "-c" ; then 
  640.   echo shar: Will not clobber existing file \"'upsd.1'\"
  641. else
  642. echo shar: Extracting \"'upsd.1'\" \(2916 characters\)
  643. sed "s/^X//" >'upsd.1' <<'END_OF_FILE'
  644. X.\"upsd release 03/30/91 version 1.0 patchlevel 3
  645. X.TH UPSD 1M
  646. X.SH NAME
  647. Xupsd \- UPS monitor daemon
  648. X.SH SYNOPSIS
  649. X.B /etc/upsd
  650. X[\-d tty] [\-c cmd] [\-l file] [\-f file] [\-r file] [\-t min]
  651. X.SH DESCRIPTION
  652. X.I Upsd
  653. Xmonitors the serial port connected to an UPS device
  654. Xand will perform an unattended shutdown of the system
  655. Xif the UPS is on battery longer than a specified
  656. Xnumber of minutes.
  657. X.I Upsd
  658. Xneeds to watch a tty with modem control properties,
  659. Xand expects the UPS to raise DCD when it switches to
  660. Xbattery backup and drop DCD when it goes back to an
  661. Xonline state.
  662. X.SH OPTIONS
  663. X.I upsd
  664. Xhas the following command line options:
  665. X.IP "-d \fItty\fP"
  666. XSpecifies the full pathname (including the /dev prefix)
  667. Xto the tty device the UPS is on.  This must be a modem
  668. Xcontrol type device.
  669. X.PP
  670. X.IP "-c \fIcmd\fP"
  671. XSpecifies the full pathname of the command to be executed
  672. Xto shut down the system.  This command must be enclosed in
  673. Xquotes if it consists of 2 or more words.
  674. X.PP
  675. X.IP "-l \fIfile\fP"
  676. XSpecifies the logfile
  677. X.I upsd
  678. Xwill write it's event messages to, these messages give the
  679. Xdate and time that the UPS daemon started, switched to battery,
  680. Xswitched back to online, executed the shutdown command, or was
  681. Xterminated via SIGTERM.
  682. X.PP
  683. X.IP "-f \fIfile\fP"
  684. XSpecifies the path name of the failure message file to broadcast
  685. Xto all users in the event of a power failure.  The failure message
  686. Xfile is simply an ASCII text file which you can create with an editor
  687. Xsuch as vi(1). If the file is not found by
  688. X.I upsd
  689. X, no message will be broadcast upon power failure.
  690. X.PP
  691. X.IP "-r \fIfile\fP"
  692. XSpecifies the path name of the restore message file to broadcast
  693. Xto all users in the event of power restore.  The restore message
  694. Xfile is simply an ASCII text file which you can create with an editor
  695. Xsuch as vi(1). If the file is not found by
  696. X.I upsd
  697. X, no message will be broadcast upon power restore.
  698. X.PP
  699. X.IP "-t \fImin\fP"
  700. XSpecifies the number of minutes to allow the UPS to be on battery
  701. Xbackup before executing the shutdown sequence.  This number must
  702. Xbe between 1 and 30.  Be careful not to choose a value greater than
  703. Xthe number of minutes of battery time your UPS supports with your
  704. Xcurrent load.  A value in the 5 to 10 minute range is probably sufficient.
  705. X.PP
  706. X.SH ENVIRONMENT VARIABLES
  707. XThe following environment variables can be set if that interface
  708. Xis preferred to the command line options.  Note that command
  709. Xline options override the environment variable settings.
  710. X.sp
  711. XEnvironment    Equivalent        Default
  712. XVariable        Command line option    Value
  713. XUPSPORT            -p            /dev/ttyFM00
  714. XUPSSHUT            -c            "/etc/shutdown -y -i0"
  715. XUPSLOG            -l            /etc/upslog
  716. XUPSFAIL            -f            /etc/upsfail
  717. XUPSREST            -r            /etc/upsrest
  718. XUPSTIME            -t            10
  719. X.sp
  720. X.SH FILES
  721. X/etc/upslog        upsd event log
  722. X.br
  723. X/etc/upsfail        upsd failure message file
  724. X.br
  725. X/etc/upsrest        upsd restore message file
  726. X.SH SEE ALSO
  727. Xshutdown(1M), wall(1).
  728. X.SH AUTHOR
  729. XArthur W. Neilson III
  730. X.br
  731. Xart@pilikia.pegasus.com
  732. END_OF_FILE
  733. if test 2916 -ne `wc -c <'upsd.1'`; then
  734.     echo shar: \"'upsd.1'\" unpacked with wrong size!
  735. fi
  736. # end of 'upsd.1'
  737. fi
  738. if test -f 'upsfail' -a "${1}" != "-c" ; then 
  739.   echo shar: Will not clobber existing file \"'upsfail'\"
  740. else
  741. echo shar: Extracting \"'upsfail'\" \(188 characters\)
  742. sed "s/^X//" >'upsfail' <<'END_OF_FILE'
  743. XUPS ONLINE POWER FAILED, UPS is now on battery backup power.
  744. XThe system will shut down automatically in 10 minutes if power
  745. Xis not restored.  Please log off the system as soon as you can.
  746. END_OF_FILE
  747. if test 188 -ne `wc -c <'upsfail'`; then
  748.     echo shar: \"'upsfail'\" unpacked with wrong size!
  749. fi
  750. # end of 'upsfail'
  751. fi
  752. if test -f 'upsrest' -a "${1}" != "-c" ; then 
  753.   echo shar: Will not clobber existing file \"'upsrest'\"
  754. else
  755. echo shar: Extracting \"'upsrest'\" \(99 characters\)
  756. sed "s/^X//" >'upsrest' <<'END_OF_FILE'
  757. XUPS ONLINE POWER RESTORED!  UPS now on wall power.
  758. XYou may resume your work and proceed as normal.
  759. END_OF_FILE
  760. if test 99 -ne `wc -c <'upsrest'`; then
  761.     echo shar: \"'upsrest'\" unpacked with wrong size!
  762. fi
  763. # end of 'upsrest'
  764. fi
  765. echo shar: End of shell archive.
  766. exit 0
  767. -----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----
  768.  
  769. -- 
  770. Arthur W. Neilson III        | INET: art@pilikia.pegasus.com
  771. Bank of Hawaii Tech Support    | UUCP: uunet!ucsd!nosc!pilikia!art
  772.  
  773. exit 0 # Just in case...
  774. -- 
  775. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  776. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  777. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  778. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  779.